import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './assets/css/global.css'
import './plugins/element.js'
import axios from 'axios'
// 引入nprogress加入进度条
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import MD5 from './util/MD5Util'
// 设置全局地址调用(并不提供任何跨域配置, 采用 devServer: 提供的代理取代 /apis)
axios.defaults.baseURL = '/apis';
// 拦截器设置请求头添加Token , 可以展示进度条 start()
axios.interceptors.request.use(config => {
    NProgress.start();
    let timestamp = new Date().getTime();
    config.headers.common['Timestamp'] = timestamp;
    config.headers.common['Authorization'] = MD5(timestamp);
    return config;
});
// response 中可以隐藏进度条 down()
axios.interceptors.response.use(config => {
    NProgress.done();
    return config;
});

// 将axios挂载到全局Vue上面
axios.defaults.timeout = 2500;
Vue.prototype.$http = axios;


Vue.config.productionTip = false;

new Vue({
    router,
    render: h => h(App)
}).$mount('#app');
